package com.atguigu.utils;

import javax.servlet.http.HttpServletRequest;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Date:2020/9/12
 * Author:ybc
 * Description:
 */
public class WebUtils {

    public static String getPath(HttpServletRequest request){
        //获取当前请求的请求路径
        String requestURI = request.getRequestURI();
        //获取请求地址后所拼接的请求参数
        String queryString = request.getQueryString();
        if(queryString.contains("&pageNo")){
            queryString = queryString.substring(0,queryString.indexOf("&pageNo"));
        }
        return requestURI+"?"+queryString;
    }

    public static void main(String[] args) {
        String reg_username = "^\\w{6,15}$";
        String username = "admin";
        username.matches(reg_username);

        Pattern.matches(reg_username, username);

        Pattern pattern = Pattern.compile(reg_username);
        Matcher matcher = pattern.matcher(username);
        matcher.matches();
    }

}
